/*
 * Project Name: jmax
 * File Name: CmdCache.java
 * Copyright: Copyright(C) 1985-2015 ZKTeco Inc. All rights reserved.
 */
package com.xdtech.hotel.protocol.cmd;

import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;


/**
 * @author max.zheng
 * @since 2015-4-3 上午11:18:00
 */
public class CmdCache
{
	protected static Queue<String> cmdQueues = new ConcurrentLinkedQueue<String>();
	
	static int i = 0;
	
	public static void main(String[] args)
	{
		
		new Thread(new Runnable()
		{
			
			@Override
			public void run()
			{
				while (true)
				{
					cmdQueues.add((++i)+"");
//					System.out.println("size"+cmdQueues.size());
					System.out.println("put");
				}
				
			}
		}, "put").start();
		
		new Thread(new Runnable()
		{
			
			@Override
			public void run()
			{
				while (true)
				{
					if (!cmdQueues.isEmpty())
					{
						System.out.println("poll===="+cmdQueues.poll());
						System.out.println("poll");
					}
				}
				
			}
		}, "poll").start();
//		cmdQueues.isEmpty();
//		for (Iterator iterator = cmdQueues.iterator(); iterator.hasNext();)
//		{
//			String type = (String) iterator.next();
//			System.out.println(type);
//		}
	}
}
